
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Scanner;

/**
 *
 * @author Bjarni
 */
public class Payment {

    private double JuniorAmount = 1000.0;
    private double SeniorAmount = 1600.0;
    private double PassiveAmount = 500.0;
    private double PensionDiscount = .25;

    public double amountToPay(Member member) {
        String age = member.getAgeGroup();
        String type = member.getMemberType();

        if (age.equals("Junior")) {
            if (type.equals("Passive")) {
                return PassiveAmount;
            } else {
                return JuniorAmount;
            }
        } else if (age.equals("Senior")) {
            if (type.equals("Passive")) {
                return PassiveAmount;
            } else {
                return SeniorAmount;
            }
        } else {
            if (type.equals("Passive")) {
                return PassiveAmount;
            } else {
                return ((int) Math.round(SeniorAmount * PensionDiscount * 100)) / 100.0;
            }
        }
    }

    public void makePayment(Member member) {
        member.setPaid(true);
    }

    public ArrayList<Member> loadAllNonPaid(String fileName) throws FileNotFoundException {
        MemberList memberList = new MemberList();
        ArrayList<DataObject> templist = memberList.loadAllObjectsFromFile(fileName);
        ArrayList<Member> list = new ArrayList<Member>();
        Member temp;
        for (int i = 0; i < templist.size(); i++) {
            temp = memberList.dataObjectToMember(templist.get(i));
            if (!temp.isPaid()) {
                list.add(temp);
            }
        }
        return list;
    }
}